<ui:composition template="/WEB-INF/templates/showcase.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:o="http://omnifaces.org/ui"
>
	<ui:define name="description">
		<p>
			The <code>&lt;o:viewParam&gt;</code> is designed to be used in combination with view scoped beans only. 
			It extends the standard <code>&lt;f:viewParam&gt;</code> and provides a stateless mode of operation. 
			The standard <code>&lt;f:viewParam&gt;</code> implementation calls the model setter again after postback.
			This is not always desired when being bound to a view scoped bean and can lead to performance problems when
			combined with an expensive converter.
		</p>
		<p>
			The <code>required="true"</code> validator is also skipped on postbacks,
			so you don't need to retain it on every single command link/button by <code>&lt;f:param&gt;</code>. 
			It also provides a default for the <code>label</code> atrribute. When the <code>label</code> attribute is 
			omitted, the <code>name</code> attribute will be used as label.
		</p>
		<p>
			As to the demo below, if this page is requested by a request without a <code>test</code> parameter, it should
			display the message	with the <code>name</code> of the <code>&lt;o:viewParam&gt;</code> as label instead of 
			its client ID:
			<br/>
			"test: Validation Error: Value is required."
		</p>
		<p>
			Clicking the GET link initiates a new GET request with a <code>test</code> parameter. Every time this
			request is issued, a converter runs that attaches an ever increasing number to the displayed
			value.
		</p>
		<p>
			Clicking the POST link initiates a POST request. This should not convert
			the value again and thus the number should not change. The POST request should also
			not cause the <code>required="true"</code> validator to be triggered.
		</p>
	</ui:define>

	<ui:define name="demo-meta">
		<f:metadata>
			<o:viewParam id="test" name="test" value="#{viewParamBean.test}" required="true" converter="testConverter" />
		</f:metadata>
	</ui:define>

	<ui:define name="demo">
		<p>
			<b>The message: </b>
			<h:message for="test" />
		</p>

		<p>
			<b>The GET link: </b>
			<h:link value="Do GET request">
				<f:param name="test" value="foo"/>
			</h:link>
		</p>

		<p>
			<h:form>
				<b>The POST link: </b>
				<h:commandLink value="Do POST request" action="#{viewParamBean.action}" />
			</h:form>
		</p>
			
		<p>
			<b>The value: </b>
			#{viewParamBean.test}
		</p>
	</ui:define>
</ui:composition>